/**
 *
 */
import Util;
import GatewayClient;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @productId = 'BPStudio';
  var gatewayClient = new GatewayClient();
  @spi = gatewayClient;
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('bpstudio', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model BillingApplicationRequest {
  month?: int32(name='Month'),
  resourceGroupId?: string(name='ResourceGroupId'),
  year?: int32(name='Year'),
}

model BillingApplicationResponseBody = {
  code?: int32(name='Code'),
  data?: int32(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model BillingApplicationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: BillingApplicationResponseBody(name='body'),
}

/**
 * @summary BillingApplication
 *
 * @param request BillingApplicationRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return BillingApplicationResponse
 */
async function billingApplicationWithOptions(request: BillingApplicationRequest, runtime: Util.RuntimeOptions): BillingApplicationResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.month)) {
    body['Month'] = request.month;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    body['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.year)) {
    body['Year'] = request.year;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'BillingApplication',
    version = '2020-07-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary BillingApplication
 *
 * @param request BillingApplicationRequest
 * @return BillingApplicationResponse
 */
async function billingApplication(request: BillingApplicationRequest): BillingApplicationResponse {
  var runtime = new Util.RuntimeOptions{};
  return billingApplicationWithOptions(request, runtime);
}

model GetDeployDetailRequest {
  appId?: string(name='AppId', description='This parameter is required.', example='30GRJUY95TMYWBYJ'),
  maxResults?: long(name='MaxResults', description='This parameter is required.', example='40'),
  nextToken?: long(name='NextToken', description='This parameter is required.', example='1'),
  refId?: string(name='RefId', example='1713597738'),
  resourceGroupId?: string(name='ResourceGroupId', example='rg-aekz44tg3bnpyba'),
  resourceId?: string(name='ResourceId', example='vsw-xxxxxxxxxxxx'),
  resourceName?: string(name='ResourceName', example='rgm-ecs'),
  resourceType?: string(name='ResourceType', example='ecs'),
}

model GetDeployDetailResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: [ 
    {
      appId?: string(name='AppId', example='EQ4W772D0VJ33IV1'),
      createTime?: long(name='CreateTime', example='1645516991000'),
      currentProcess?: string(name='CurrentProcess', example='DEPLOY'),
      deletingNodeList?: [  map[string]any ](name='DeletingNodeList'),
      deployPercent?: double(name='DeployPercent', example='0'),
      deployedNodeList?: [  map[string]any ](name='DeployedNodeList'),
      deployingNodeList?: [  map[string]any ](name='DeployingNodeList'),
      error?: string(name='Error', example='OperationNotSupport.SubscriptionCommodityCanNotDelete'),
      executionTime?: int32(name='ExecutionTime'),
      failStatus?: int32(name='FailStatus'),
      orderIdList?: [ string ](name='OrderIdList'),
      pdfUrl?: string(name='PdfUrl', example='https://cadt-studio-publish.oss-cn-hangzhou.aliyuncs.com/1986207497633020/deployReport-EXN4FNUR12M35KJM.pdf?Expires=1716967763&OSSAccessKeyId=********nw4rvYAweFuQc3&Signature=*******fKo6164wykT9jBOsSGeQ%3D'),
      resourceGroupId?: string(name='ResourceGroupId', example='rg-aekzhfgmw4e6fwq'),
      resourceList?: [ 
        {
          buyDuration?: string(name='BuyDuration'),
          chargeType?: string(name='ChargeType', example='Free'),
          executionStrategy?: string(name='ExecutionStrategy', example='OpenApi'),
          expiredTime?: long(name='ExpiredTime'),
          modifiedTime?: long(name='ModifiedTime', example='1714031840000'),
          monitorURL?: string(name='MonitorURL', example='https://cloudmonitor.console.aliyun.com/?#/generalcharts/product=vpc&group=&type=&return&region=cn-hangzhou&dimension=instanceId:vpc-bp1n6uc5jqxtff2euhnx5'),
          nodeName?: string(name='NodeName', example='vpc'),
          operation?: {
            name?: string(name='Name', example='ecsDelete'),
            operations?: map[string]any(name='Operations'),
          }(name='Operation'),
          refId?: long(name='RefId', example='1716049421'),
          remark?: string(name='Remark', example='{\\\\"Description\\\\":\\\\"\\\\",\\\\"ClassicLinkEnabled\\\\":false,\\\\"ResourceGroupId\\\\":\\\\"rg-acfm4mlwqjalz7a\\\\",\\\\"SecondaryCidrBlocks\\\\":[],\\\\"CidrBlock\\\\":\\\\"192.168.0.0/16\\\\",\\\\"UserCidrs\\\\":[],\\\\"NetworkAclNum\\\\":\\\\"0\\\\",\\\\"VRouterId\\\\":\\\\"vrt-m5ek7vcyld0x5ym8m9hix\\\\",\\\\"OwnerId\\\\":1986207497633020,\\\\"AssociatedCens\\\\":[],\\\\"id\\\\":\\\\"vpc-m5e3c9nz4lj19byan9m2g\\\\",\\\\"CloudResources\\\\":[{\\\\"ResourceCount\\\\":1,\\\\"ResourceType\\\\":\\\\"VSwitch\\\\"},{\\\\"ResourceCount\\\\":1,\\\\"ResourceType\\\\":\\\\"VRouter\\\\"},{\\\\"ResourceCount\\\\":1,\\\\"ResourceType\\\\":\\\\"RouteTable\\\\"}],\\\\"Tags\\\\":[],\\\\"Status\\\\":\\\\"Available\\\\",\\\\"IsDefault\\\\":false,\\\\"RequestId\\\\":\\\\"494646FB-14C0-5B4C-9684-B6EFBF4DF01C\\\\",\\\\"SupportIpv4Gateway\\\\":false,\\\\"Ipv4GatewayId\\\\":\\\\"\\\\",\\\\"VSwitchIds\\\\":[\\\\"vsw-m5egl9wtppiadysjwlgb1\\\\"],\\\\"VpcId\\\\":\\\\"vpc-m5e3c9nz4lj19byan9m2g\\\\",\\\\"CreationTime\\\\":\\\\"2024-04-25T07:56:59Z\\\\",\\\\"VpcName\\\\":\\\\"vpc\\\\",\\\\"refId\\\\":\\\\"1714031764_0\\\\",\\\\"RegionId\\\\":\\\\"cn-qingdao\\\\",\\\\"Ipv6CidrBlock\\\\":\\\\"\\\\",\\\\"Ipv6CidrBlocks\\\\":[]}'),
          resourceCode?: string(name='ResourceCode', example='ecs'),
          resourceId?: string(name='ResourceId', example='i-2zehnzxqixu1pywsfbx1'),
          resourceTimeList?: [ 
            {
              bizId?: string(name='BizId'),
              creationEndTime?: long(name='CreationEndTime'),
              creationStartTime?: long(name='CreationStartTime'),
              id?: long(name='id'),
            }
          ](name='ResourceTimeList'),
          resourceType?: string(name='ResourceType', example='vpc'),
          status?: string(name='Status', example='Finish'),
        }
      ](name='ResourceList'),
      status?: string(name='Status', example='Revised'),
      terraformScriptUrl?: string(name='TerraformScriptUrl', example='https://cadt-studio-publish.oss-cn-hangzhou.aliyuncs.com/1986207497633020/app_EXN4FNUR12M35KJM.tf?Expires=1716967763&OSSAccessKeyId=*******nw4rvYAweFuQc3&Signature=%2********lYROqJLNvyA8g6qD9U%3D'),
    }
  ](name='Data'),
  message?: string(name='Message', example='Success'),
  nextToken?: long(name='NextToken', example='0'),
  requestId?: string(name='RequestId', example='E15B71B4-5D8F-5484-BC07-989E2987EE7C'),
  totalCount?: long(name='TotalCount', example='10'),
}

model GetDeployDetailResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetDeployDetailResponseBody(name='body'),
}

/**
 * @summary 分页查询部署清单
 *
 * @param request GetDeployDetailRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetDeployDetailResponse
 */
async function getDeployDetailWithOptions(request: GetDeployDetailRequest, runtime: Util.RuntimeOptions): GetDeployDetailResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.appId)) {
    body['AppId'] = request.appId;
  }
  if (!Util.isUnset(request.maxResults)) {
    body['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    body['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.refId)) {
    body['RefId'] = request.refId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    body['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceId)) {
    body['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceName)) {
    body['ResourceName'] = request.resourceName;
  }
  if (!Util.isUnset(request.resourceType)) {
    body['ResourceType'] = request.resourceType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetDeployDetail',
    version = '2020-07-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 分页查询部署清单
 *
 * @param request GetDeployDetailRequest
 * @return GetDeployDetailResponse
 */
async function getDeployDetail(request: GetDeployDetailRequest): GetDeployDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDeployDetailWithOptions(request, runtime);
}

